﻿#region 命名空间

using System;
using System.Web;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Explorer
{
    [Access("258002")]
    public partial class DownloadFile : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            try
            {
                var thepath = Request["dir"];
                var thefile = new System.IO.FileInfo(thepath);
                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Length", thefile.Length.ToString());
                Response.AddHeader("Content-Disposition",
                    "attachment; filename=" + HttpUtility.UrlEncode(thefile.Name, System.Text.Encoding.UTF8));
                Response.WriteFile(thefile.FullName);
                Response.End();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
    }
}